package com.cloudy.impl;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;


import static com.cloudy.utility.CloudyUtility.*;


public class SuccessHandlerWithFileSave extends SuccessHandler {
	private String fileName;

	public SuccessHandlerWithFileSave(String fileName) {
		this.fileName = fileName;
	}

	@Override
	protected <T> T getTheResponseMessage(HttpURLConnection httpConnection)
			throws IOException {
		InputStream in = httpConnection.getInputStream();
		OutputStream out = new FileOutputStream(fileName);		
		transferBytesFromIn2Out(in, out);
		return null;
	}
}
